package com.ibeeking.found.content.b.rest.controller.v1;

import com.ibeeking.found.content.b.rest.service.IBroadcastCommentService;
import com.ibeeking.found.content.b.rest.service.IBroadcastGroupService;
import com.ibeeking.found.content.service.common.query.BroadcastCommentPageQuery;
import com.ibeeking.found.content.service.common.query.BroadcastGroupQuery;
import com.ibeeking.found.content.service.common.vo.BroadcastCommentVO;
import com.ibeeking.found.content.service.common.vo.BroadcastGroupVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName BroadcastController控制器
 * @Description
 * @Author ibeeking
 * @Date 2022-02-18 14:11
 **/
@RestController
@RequestMapping("/b/broadcast/v1/comment")
public class BroadcastCommentController {

    @Resource
    private IBroadcastCommentService broadcastCommentServiceImpl;
    @Resource
    private IBroadcastGroupService broadcastGroupService;

    /**
     * 评论管理
     */
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "评论分页列表")
    @PostMapping(value = "/pageList")
    public Page<BroadcastCommentVO> commentPageList(@RequestBody BroadcastCommentPageQuery broadcastCommentPageQuery) {
        return broadcastCommentServiceImpl.pageList(broadcastCommentPageQuery);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "评论查看")
    @GetMapping(value = "/view/{id}")
    public BroadcastCommentVO commentView(@PathVariable("id") Long id) {
        return broadcastCommentServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "评论公开状态修改")
    @PostMapping(value = "/changeStatus/{id}/{status}")
    public Boolean commentChangeStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        return broadcastCommentServiceImpl.changeStatus(id, status);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "查询直播分组列表")
    @PostMapping(value = "/group/list")
    public List<BroadcastGroupVO> broadcastGroupList(@RequestBody BroadcastGroupQuery groupQuery) {
        return broadcastGroupService.list(groupQuery);
    }
}
